<html>
<head><meta charset="utf-8"><title>needs_drop · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html">needs_drop</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="175610528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610528">(Sep 13 2019 at 10:21)</a>:</h4>
<p>Is there a <code>needs_drop</code> RFC somewhere ? I can't find it.</p>



<a name="175610739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610739">(Sep 13 2019 at 10:25)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> you said:</p>
<blockquote>
<p>For types without a Drop impl it isn't correct as these types may have recursive drop glue due to fields having Drop impls (or at any level transitively).</p>
</blockquote>
<p>But <code>needs_drop</code> returns <code>true</code> for such types, and we guarantee that</p>



<a name="175610786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610786">(Sep 13 2019 at 10:26)</a>:</h4>
<p>As in, <code>needs_drop</code> returns true if a type _needs drop glue_, independently of whether the type itself is <code>Drop</code> or not</p>



<a name="175610802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610802">(Sep 13 2019 at 10:26)</a>:</h4>
<p>we don't guarantee <code>false</code> :P</p>



<a name="175610813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610813">(Sep 13 2019 at 10:26)</a>:</h4>
<p>no?</p>



<a name="175610826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610826">(Sep 13 2019 at 10:27)</a>:</h4>
<p>For which type does that fail ?</p>



<a name="175610833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610833">(Sep 13 2019 at 10:27)</a>:</h4>
<p>how can we guarantee true and false at the same time?</p>



<a name="175610834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610834">(Sep 13 2019 at 10:27)</a>:</h4>
<p>(I can't find an RFC)</p>



<a name="175610852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610852">(Sep 13 2019 at 10:27)</a>:</h4>
<p>I don't understand the question</p>



<a name="175610863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610863">(Sep 13 2019 at 10:27)</a>:</h4>
<p>If a type does not need drop glue, we return false, if it does, we return true</p>



<a name="175610927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610927">(Sep 13 2019 at 10:28)</a>:</h4>
<p>are there types that both need and don't need drop glue, or types for which that cannot be computed ?</p>



<a name="175610952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175610952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175610952">(Sep 13 2019 at 10:29)</a>:</h4>
<p>The nomicon specifically defines types that need drop glue as "needs drop" types, so I'd supposed that <code>needs_drop</code> would implement the nomicon semantics</p>



<a name="175611057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611057">(Sep 13 2019 at 10:30)</a>:</h4>
<p>The docs of <code>std::mem::needs_drop</code> do indeed say that the answer doesn't need to be accurate:</p>
<blockquote>
<p>This is purely an optimization hint, and may be implemented conservatively: it may return true for types that don't actually need to be dropped.</p>
</blockquote>



<a name="175611181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611181">(Sep 13 2019 at 10:32)</a>:</h4>
<p>This is the only place I can find with any discussion about this: <a href="https://github.com/rust-lang/rust/pull/41892" target="_blank" title="https://github.com/rust-lang/rust/pull/41892">https://github.com/rust-lang/rust/pull/41892</a></p>



<a name="175611214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611214">(Sep 13 2019 at 10:33)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> seems to suggest here that this is an implementation bug: <a href="https://github.com/rust-lang/rust/pull/41892#discussion_r116155381" target="_blank" title="https://github.com/rust-lang/rust/pull/41892#discussion_r116155381">https://github.com/rust-lang/rust/pull/41892#discussion_r116155381</a></p>



<a name="175611275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611275">(Sep 13 2019 at 10:34)</a>:</h4>
<p>No idea if there is an open issue tracking that bug</p>



<a name="175611620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611620">(Sep 13 2019 at 10:41)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> we do not guarantee that a type with drop glue has <code>needs_drop::&lt;Type&gt;() == false</code></p>



<a name="175611626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611626">(Sep 13 2019 at 10:41)</a>:</h4>
<p>why</p>



<a name="175611680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611680">(Sep 13 2019 at 10:42)</a>:</h4>
<p>wait, that's correct</p>



<a name="175611691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611691">(Sep 13 2019 at 10:42)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span>  I think you were mixing up true &amp; false</p>



<a name="175611693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611693">(Sep 13 2019 at 10:42)</a>:</h4>
<p>types with drop glue should always have <code>needs_drop::&lt;Type&gt;() == true</code></p>



<a name="175611698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611698">(Sep 13 2019 at 10:42)</a>:</h4>
<p>yes, correct</p>



<a name="175611703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611703">(Sep 13 2019 at 10:42)</a>:</h4>
<p>which is what I was saying in the thing you quoted</p>



<a name="175611711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611711">(Sep 13 2019 at 10:43)</a>:</h4>
<p>we don't guarantee that types _without_ drop glue have <code>needs_drop::&lt;Type&gt;() == false</code></p>



<a name="175611722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611722">(Sep 13 2019 at 10:43)</a>:</h4>
<p>also correct</p>



<a name="175611728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611728">(Sep 13 2019 at 10:43)</a>:</h4>
<p><code>needs_drop</code> can return <code>true</code> for them, and that isn't a correctness issue</p>



<a name="175611731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611731">(Sep 13 2019 at 10:43)</a>:</h4>
<p>the question is why don't we guarantee that</p>



<a name="175611736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611736">(Sep 13 2019 at 10:43)</a>:</h4>
<p>why don't we guarantee that for types without drop glue <code>needs_drop</code> always returns <code>false</code> ?</p>



<a name="175611785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611785">(Sep 13 2019 at 10:44)</a>:</h4>
<p>well if you do that then you have guaranteed this as a matter of semver for all crates</p>



<a name="175611797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611797">(Sep 13 2019 at 10:44)</a>:</h4>
<p>doing it for <code>Copy</code> is a more explicit commitment which already has semver implications</p>



<a name="175611798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611798">(Sep 13 2019 at 10:44)</a>:</h4>
<p>sure, so are many other things</p>



<a name="175611806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611806">(Sep 13 2019 at 10:44)</a>:</h4>
<p>AFAICT, we could have a <code>NeedsDrop</code> auto-trait, and then <code>mem::needs_drop</code> can be implemented using specialization: </p>
<div class="codehilite"><pre><span></span><span class="n">auto</span><span class="w"> </span><span class="k">trait</span><span class="w"> </span><span class="n">NeedsDrop</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">NeedsDrop</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="n">T</span>: <span class="nb">Drop</span> <span class="p">{}</span><span class="w"></span>
<span class="k">trait</span><span class="w"> </span><span class="n">_ComputeNeedsDrop</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">default</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">VALUE</span>: <span class="kt">bool</span> <span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="n">default</span><span class="w"> </span><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">_ComputeNeedsDrop</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">NeedsDrop</span><span class="o">&gt;</span><span class="w"> </span><span class="n">_ComputeNeedsDrop</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">VALUE</span>: <span class="kt">bool</span> <span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">needs_drop</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">_ComputeNeedsDrop</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"> </span><span class="n">T</span>::<span class="n">VALUE</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="175611818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611818">(Sep 13 2019 at 10:45)</a>:</h4>
<p>It's not a question of "can", it's a question of "want".</p>



<a name="175611825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611825">(Sep 13 2019 at 10:45)</a>:</h4>
<p>so where is the rationale that says that doing so is a bad idea</p>



<a name="175611833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611833">(Sep 13 2019 at 10:45)</a>:</h4>
<p>the only rationale I can find is that given by @eddyb on that issue</p>



<a name="175611844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611844">(Sep 13 2019 at 10:45)</a>:</h4>
<p>which says, we can't do this on the compiler two years ago because of associated types</p>



<a name="175611850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611850">(Sep 13 2019 at 10:46)</a>:</h4>
<p>it doesn't say anything about it being a good or bad idea</p>



<a name="175611914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611914">(Sep 13 2019 at 10:46)</a>:</h4>
<p>and i mean, the compiler has to be able to know precisely whether a type needs drop glue or not..</p>



<a name="175611937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611937">(Sep 13 2019 at 10:47)</a>:</h4>
<p>(specialization isn't stable)</p>



<a name="175611943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611943">(Sep 13 2019 at 10:47)</a>:</h4>
<blockquote>
<p>it doesn't say anything about it being a good or bad idea</p>
</blockquote>
<p>I'm saying that we should be careful with more auto traits and such semver commitments</p>



<a name="175611989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175611989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175611989">(Sep 13 2019 at 10:48)</a>:</h4>
<p>I do think it's probably a bad idea</p>



<a name="175612002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175612002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175612002">(Sep 13 2019 at 10:48)</a>:</h4>
<p><code>Copy</code> is still quite a lot of types</p>



<a name="175626717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175626717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175626717">(Sep 13 2019 at 14:05)</a>:</h4>
<p>it's a bug because it's not computed by the trait system</p>



<a name="175626719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175626719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175626719">(Sep 13 2019 at 14:05)</a>:</h4>
<p>that's it</p>



<a name="175626754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175626754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175626754">(Sep 13 2019 at 14:06)</a>:</h4>
<p>that's all  there is to it</p>



<a name="175626782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175626782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175626782">(Sep 13 2019 at 14:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116083">@pnkfelix</span> might have more info</p>



<a name="175626831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175626831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175626831">(Sep 13 2019 at 14:06)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> ah I see you mention specialization. I hope that doesn't work, I don't think I've heard anything about autotraits being sound wrt specialization</p>



<a name="175630528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175630528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175630528">(Sep 13 2019 at 14:42)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> I don't specialize an auto trait, I just use them in bounds</p>



<a name="175630532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175630532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175630532">(Sep 13 2019 at 14:42)</a>:</h4>
<p>is that unsound?</p>



<a name="175630562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175630562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175630562">(Sep 13 2019 at 14:42)</a>:</h4>
<p>that might work</p>



<a name="175630593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175630593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175630593">(Sep 13 2019 at 14:43)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> </p>
<blockquote>
<p>(specialization isn't stable)</p>
</blockquote>
<p><code>needs_drop</code> is already a <code>#[lang_item]</code> - how we implement it internally doesn't really matter</p>



<a name="175630602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175630602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175630602">(Sep 13 2019 at 14:43)</a>:</h4>
<p>surprises me that you can do that, I thought you needed Copy to change the auto trait behavior</p>



<a name="175630635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175630635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175630635">(Sep 13 2019 at 14:43)</a>:</h4>
<p>wait you don't have Copy in there. so it's not the whole story</p>



<a name="175631111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631111">(Sep 13 2019 at 14:48)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span>  <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=411c333b1681a2893d187a847364c4bb" target="_blank" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=411c333b1681a2893d187a847364c4bb">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=411c333b1681a2893d187a847364c4bb</a></p>



<a name="175631189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631189">(Sep 13 2019 at 14:49)</a>:</h4>
<p>yeah sure I think that's fine, the problem is that a non-Copy type wrapping a Copy type, needs to be !NeedsDrop</p>



<a name="175631227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631227">(Sep 13 2019 at 14:49)</a>:</h4>
<p>so like <code>Cell&lt;T&gt;</code> where <code>T: Copy</code></p>



<a name="175631284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631284">(Sep 13 2019 at 14:50)</a>:</h4>
<p>your version would work if you knew the type fully, I guess?</p>



<a name="175631312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631312">(Sep 13 2019 at 14:50)</a>:</h4>
<p>one can only call <code>needs_drop</code> will a full type</p>



<a name="175631359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631359">(Sep 13 2019 at 14:51)</a>:</h4>
<p>well, yes, but what is being run on the compiler doesn't need to be fully concrete</p>



<a name="175631380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631380">(Sep 13 2019 at 14:51)</a>:</h4>
<p>it's how we avoid generating drops for locals in MIR</p>



<a name="175631434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631434">(Sep 13 2019 at 14:51)</a>:</h4>
<p>having two computations seems risky</p>



<a name="175631523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631523">(Sep 13 2019 at 14:52)</a>:</h4>
<p>Ah gotcha</p>



<a name="175631575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631575">(Sep 13 2019 at 14:53)</a>:</h4>
<p><code>Copy</code> is kind of <code>Copy: !NeedsDrop</code></p>



<a name="175631582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631582">(Sep 13 2019 at 14:53)</a>:</h4>
<p>also, pretty sure miri can evaluate <em>and constant-fold</em> needs_drop already (cc <span class="user-mention" data-user-id="124288">@oli</span>)</p>



<a name="175631606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631606">(Sep 13 2019 at 14:53)</a>:</h4>
<p>yes <code>needs_drop</code> is <code>const fn</code></p>



<a name="175631636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631636">(Sep 13 2019 at 14:53)</a>:</h4>
<p>even when the type is generic</p>



<a name="175631649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631649">(Sep 13 2019 at 14:53)</a>:</h4>
<p>actually I can test this</p>



<a name="175631691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631691">(Sep 13 2019 at 14:54)</a>:</h4>
<p>ah wow</p>



<a name="175631731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631731">(Sep 13 2019 at 14:54)</a>:</h4>
<p>in all cases ?</p>



<a name="175631738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631738">(Sep 13 2019 at 14:54)</a>:</h4>
<p>or only if the type is copy ?</p>



<a name="175631783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631783">(Sep 13 2019 at 14:55)</a>:</h4>
<p>oh wait maybe I'm wrong</p>



<a name="175631795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631795">(Sep 13 2019 at 14:55)</a>:</h4>
<p>The <code>needs_drop</code> in </p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nb">Copy</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"> </span><span class="n">needs_drop</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>can always be folded to <code>false</code>.</p>



<a name="175631832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631832">(Sep 13 2019 at 14:55)</a>:</h4>
<p>but without the <code>T: Copy</code> bound I don't think one can do anything</p>



<a name="175631841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631841">(Sep 13 2019 at 14:55)</a>:</h4>
<p>it certainly <em>could</em> but it's not obvious that the answer is only guaranteed if it's <code>false</code></p>



<a name="175631916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631916">(Sep 13 2019 at 14:56)</a>:</h4>
<p>if it's <code>true</code> the real answer might be <code>false</code>. so we're missing an explicit "unknowable" result</p>



<a name="175631933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631933">(Sep 13 2019 at 14:56)</a>:</h4>
<p>the trait system has a way to represent "not sure"</p>



<a name="175631966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631966">(Sep 13 2019 at 14:56)</a>:</h4>
<p>so does <code>layout_of</code> (<code>Err(LayoutError::Unknown(_))</code>)</p>



<a name="175631969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175631969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175631969">(Sep 13 2019 at 14:56)</a>:</h4>
<p>well sure</p>



<a name="175632018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175632018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175632018">(Sep 13 2019 at 14:57)</a>:</h4>
<p>if we had a <code>NeedsDrop</code> trait we could constant fold it to true (T: NeedsDrop) or false (T: !NeedsDrop or T: Copy) or maybe (T - no bounds)</p>



<a name="175632103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175632103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175632103">(Sep 13 2019 at 14:58)</a>:</h4>
<p>Maybe is just an unknown that is resolved later if the function is ever monomorphized</p>



<a name="175632214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175632214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175632214">(Sep 13 2019 at 14:59)</a>:</h4>
<p>Ah i think I see the problem now</p>



<a name="175632367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175632367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175632367">(Sep 13 2019 at 15:00)</a>:</h4>
<p>How does this work for <code>Send</code> and <code>Sync</code> ?</p>



<a name="175640077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175640077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175640077">(Sep 13 2019 at 16:25)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> can we reliably compute needs_drop for unsized trait objects?</p>



<a name="175640114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175640114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175640114">(Sep 13 2019 at 16:25)</a>:</h4>
<p>(to me it soulds like it will have to return <code>true</code> regardless of the concrete type behind the object)</p>



<a name="175640768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175640768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175640768">(Sep 13 2019 at 16:33)</a>:</h4>
<p>Yes but that's not really an inaccuracy. The trait object does have drop glue (stored in the vtable), it just happens to be trivial for some values of that type. Not entirely unlike how <code>Option&lt;T&gt;</code> needs_drop if <code>T</code> does but dropping <code>None</code> does nothing.</p>



<a name="175747531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175747531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175747531">(Sep 15 2019 at 12:50)</a>:</h4>
<p>we probably need a new "drop-like" trait for const anyway... something to attach <code>const</code> to to say "dropping this type is possible in const context"</p>



<a name="175747532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175747532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175747532">(Sep 15 2019 at 12:50)</a>:</h4>
<p>I wanted to repurpose <code>Drop</code> for this but most likely it is way too late for this... we should not have stabilized <code>Drop</code> trait bounds :/</p>



<a name="175761939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175761939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175761939">(Sep 15 2019 at 19:12)</a>:</h4>
<p>why not?</p>



<a name="175761996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175761996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175761996">(Sep 15 2019 at 19:14)</a>:</h4>
<p>We could say that, if a field of an aggregate implements <code>Drop</code>, and the aggregate has no user-provided <code>Drop</code> impl, the compiler auto-generates a <code>Drop</code> impl for you</p>



<a name="175761998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175761998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175761998">(Sep 15 2019 at 19:14)</a>:</h4>
<p>That is, a type with a field that is <code>Drop</code> is always <code>Drop</code></p>



<a name="175762003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175762003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175762003">(Sep 15 2019 at 19:14)</a>:</h4>
<p>If the <code>Drop</code> impl for the field is <code>const</code>, the <code>Drop</code> impl for the aggregate might be able to be <code>const</code> as well</p>



<a name="175762060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175762060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175762060">(Sep 15 2019 at 19:16)</a>:</h4>
<p>This would mean that <code>needs_drop&lt;T&gt;</code> would just return whether a type is <code>Drop</code></p>



<a name="175762070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175762070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175762070">(Sep 15 2019 at 19:17)</a>:</h4>
<p>(true if it is, false if it isn't, and in generic code a "maybe" until the answer is known)</p>



<a name="175765531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175765531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175765531">(Sep 15 2019 at 20:51)</a>:</h4>
<blockquote>
<p>We could say that, if a field of an aggregate implements <code>Drop</code>, and the aggregate has no user-provided <code>Drop</code> impl, the compiler auto-generates a <code>Drop</code> impl for you</p>
</blockquote>
<p>that's not backwards-compatible: <a href="https://github.com/rust-lang/rfcs/pull/2632#issuecomment-528461395" target="_blank" title="https://github.com/rust-lang/rfcs/pull/2632#issuecomment-528461395">https://github.com/rust-lang/rfcs/pull/2632#issuecomment-528461395</a></p>



<a name="175767566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175767566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175767566">(Sep 15 2019 at 21:47)</a>:</h4>
<p>that's bad</p>



<a name="175797778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/needs_drop/near/175797778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/needs_drop.html#175797778">(Sep 16 2019 at 09:45)</a>:</h4>
<p>yes :(</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>